<script src="js/jquery.js"> </script>	
<meta charset="utf-8">
<link rel="stylesheet" href="css/csstb.css" type="text/css" media="screen" />
<form action="Javascript:insertprice();" name="price_pop" id="price_pop" method="post">
<?php
require("db/connect.php");
require("prename.php");
$sql="select cus_title,deposit_price,cus_name,cus_lastname,SUM(qty*pro_price) as sumprice from orders,cart,deposit,product,customer
 where orders.orders_id=cart.orderid and orders.orders_id=deposit.orders_id and cart.pro_id=product.pro_id and orders.cus_id=customer.cus_id and orders.orders_id=".$_GET["order"]."";
$query=mysql_query($sql);
$result=mysql_fetch_array($query);

 ?>
 <style>
 body {
	 
    /*background-image :url("img/pyk.jpg");
    background-repeat: no-repeat;
    background-position:top;*/
}
</style>
 <div align="center"><img src="img/pyk.JPG"  width="330" height="240" /></div>
  <table width="516" border="10" style="border-color:#3F3">
    <tr>
      <td width="198">เลขที่ใบสั่งซื้อ</td>
      <td width="159"><?php echo $_GET["order"] ?></td>
    </tr>
    <tr>
      <td height="27">ผู้สั่งซื้อ</td>
      <td><?php echo (prename($result["cus_title"])."".$result["cus_name"])." ".$result["cus_lastname"]?></td>
    </tr>
      <tr>
      <td height="27">จำนวนเงินทั้งหมด</td>
      <td>
        <label for="textfield"></label>
       <input name="allprice" type="number" id="allprice" value="<?php echo $result["sumprice"]  ?>" disabled="disabled" /></td>
    </tr>
      <tr>
      <td height="27">จำนวนเงินที่มัดจำ</td>
      <td>
        <label for="textfield"></label>
       <input name="sumprice" type="number" id="sumprice" value="<?php echo $result["deposit_price"]  ?>" disabled="disabled" /></td>
    </tr>
     <tr>
      <td height="27">จำนวนเงินชำระ</td>
      <td><?php  ?>
        <label for="textfield"></label>
       <input name="price"  type="number" id="price" value="<?php echo $result["sumprice"]-$result["deposit_price"]  ?>"   placeholder="กรอกจำนวนเงินที่ชำระ" disabled="disabled" /></td>
    </tr>

  </table>
  <p align="center">
    <input type="submit" name="button" id="button" value="บันทึกข้อมูลการชำระเงิน">
    <input type="button" name="button2" id="button2" value="ยกเลิกการชำระเงิน" onClick="window.close();">
  </p>
  <script>
		 
		 function insertprice(){
			 
			 $.ajax({
				 url:'update_order.php?orders_id=<?php echo $_GET["order"]?>&status=001',
				 type:"POST",
				 success: function(msg){
					 alert("อัพเดทสถานะเสร็จสิ้น");
					 //console.log(msg);
					 if (window.opener != null && !window.opener.closed) {
                window.opener.location.reload();
				window.close();
          			  }
	 					window.onbeforeunload = RefreshParent;
					 }
				 });
			 }
  </script>
</form>